﻿
using System.ComponentModel;
using System;

namespace MediaBrowserSL.RIA.MediaBrowserServiceReference
{
    /// <summary>
    /// Media Extension
    /// </summary>
    public partial class Media : IDataErrorInfo
    {
        #region Private member
        private String error;
        #endregion

        #region IDataErrorInfo Members

        public string Error
        {
            get { return error; }
        }

        public string this[string columnName]
        {
            get
            {
                error = null;

                if (columnName == "Name")
                {
                    if ((Name != null) && (Name.Equals("")))
                        error = "Le Nom est un champ obligatoire";
                }
                else if (columnName == "Description")
                {
                    if ((Description != null) && (Description.Equals("")))
                        error = "La description est un champ obligatoire";
                }

                return error;
            }
        }

        #endregion

        #region Public Methods
        public bool ValidData()
        {
            bool result = true;

            if ((String.IsNullOrEmpty(Name)) || (String.IsNullOrEmpty(Description)))
                result = false;

            return result;

        }

        public Media Clone()
        {
            return new Media()
            {
                Id = this.Id,
                Name = this.Name,
                Description = this.Description,
                UrlContent = this.UrlContent,
                UrlImage = this.UrlImage,
                CreationDate = this.CreationDate,
                User = this.User
            };
        }

        #endregion
    }
}
